<?php
/**
 * Created by PhpStorm.
 * User: ybjaa
 * Date: 2017/5/4
 * Time: 10:14
 */

namespace App\Business\Menu;

use App\Business\Model\Menu;
use App\Models\menus_manage;
use App\Units;

class GetTopMenus extends MenusBase
{
    protected function Handle()
    {
        return $this->GetTopMenus();
    }


    public function GetBusinessName()
    {
        return "获得顶层菜单";
    }


    protected function GetTopMenus()
    {
        $menus= menus_manage::where("parentID",0)->get();


        if($menus==null || count($menus)<=0) return null;

        //转化为业务模型对象
        $topMenus=Units::ArrayToObject($menus->toArray(),Menu::class);

        //排序
        $topMenus=$this->menuSort($topMenus);
        return array_values($topMenus);

    }





}